using System;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;

namespace DataEntity
{
	public class T_Project_Confirmation : DBInteractionBase
	{
		#region Class Member Declarations
			private SqlDateTime		_project_Confirmation_Date, _project_Confirmation_CommissionDate;
			private SqlInt32		_project_Confirmation_Status;
			private SqlDecimal		_project_Confirmation_DeveloperAmount, _project_Confirmation_PartCommission, _project_Confirmation_Amount;
			private SqlString		_project_Confirmation_NO;
			private SqlGuid			_project_Confirmation_ID, _project_Confirmation_CommissionID;
		#endregion


		public T_Project_Confirmation()
		{
			// Nothing for now.
		}


	




		public override bool Delete()
		{
			SqlCommand	cmdToExecute = new SqlCommand();
			cmdToExecute.CommandText = "dbo.[sp_t_Project_Confirmation_Delete]";
			cmdToExecute.CommandType = CommandType.StoredProcedure;

			// Use base class' connection object
			cmdToExecute.Connection = _mainConnection;

			try
			{
				cmdToExecute.Parameters.Add(new SqlParameter("@guidProject_Confirmation_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, _project_Confirmation_ID));

				if(_mainConnectionIsCreatedLocal)
				{
					// Open connection.
					_mainConnection.Open();
				}
				else
				{
					if(_mainConnectionProvider.IsTransactionPending)
					{
						cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
					}
				}

				// Execute query.
				_rowsAffected = cmdToExecute.ExecuteNonQuery();
				return true;
			}
			catch(Exception ex)
			{
				// some error occured. Bubble it to caller and encapsulate Exception object
				throw new Exception("T_Project_Confirmation::Delete::Error occured.", ex);
			}
			finally
			{
				if(_mainConnectionIsCreatedLocal)
				{
					// Close connection.
					_mainConnection.Close();
				}
				cmdToExecute.Dispose();
			}
		}





		public override DataTable SelectAll()
		{
			SqlCommand	cmdToExecute = new SqlCommand();
			cmdToExecute.CommandText = "dbo.[sp_t_Project_Confirmation_SelectAll]";
			cmdToExecute.CommandType = CommandType.StoredProcedure;
			DataTable toReturn = new DataTable("t_Project_Confirmation");
			SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);

			// Use base class' connection object
			cmdToExecute.Connection = _mainConnection;

			try
			{

				if(_mainConnectionIsCreatedLocal)
				{
					// Open connection.
					_mainConnection.Open();
				}
				else
				{
					if(_mainConnectionProvider.IsTransactionPending)
					{
						cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
					}
				}

				// Execute query.
				adapter.Fill(toReturn);
				return toReturn;
			}
			catch(Exception ex)
			{
				// some error occured. Bubble it to caller and encapsulate Exception object
				throw new Exception("T_Project_Confirmation::SelectAll::Error occured.", ex);
			}
			finally
			{
				if(_mainConnectionIsCreatedLocal)
				{
					// Close connection.
					_mainConnection.Close();
				}
				cmdToExecute.Dispose();
				adapter.Dispose();
			}
		}


		#region Class Property Declarations
		public SqlGuid Project_Confirmation_ID
		{
			get
			{
				return _project_Confirmation_ID;
			}
			set
			{
				SqlGuid project_Confirmation_IDTmp = (SqlGuid)value;
				if(project_Confirmation_IDTmp.IsNull)
				{
					//throw new ArgumentOutOfRangeException("Project_Confirmation_ID", "Project_Confirmation_ID can't be NULL");
				}
				_project_Confirmation_ID = value;
			}
		}


		public SqlGuid Project_Confirmation_CommissionID
		{
			get
			{
				return _project_Confirmation_CommissionID;
			}
			set
			{
				SqlGuid project_Confirmation_CommissionIDTmp = (SqlGuid)value;
				if(project_Confirmation_CommissionIDTmp.IsNull)
				{
					throw new ArgumentOutOfRangeException("Project_Confirmation_CommissionID", "Project_Confirmation_CommissionID can't be NULL");
				}
				_project_Confirmation_CommissionID = value;
			}
		}


		public SqlString Project_Confirmation_NO
		{
			get
			{
				return _project_Confirmation_NO;
			}
			set
			{
				SqlString project_Confirmation_NOTmp = (SqlString)value;
				if(project_Confirmation_NOTmp.IsNull)
				{
					throw new ArgumentOutOfRangeException("Project_Confirmation_NO", "Project_Confirmation_NO can't be NULL");
				}
				_project_Confirmation_NO = value;
			}
		}


		public SqlDecimal Project_Confirmation_Amount
		{
			get
			{
				return _project_Confirmation_Amount;
			}
			set
			{
				SqlDecimal project_Confirmation_AmountTmp = (SqlDecimal)value;
				if(project_Confirmation_AmountTmp.IsNull)
				{
					throw new ArgumentOutOfRangeException("Project_Confirmation_Amount", "Project_Confirmation_Amount can't be NULL");
				}
				_project_Confirmation_Amount = value;
			}
		}


		public SqlDateTime Project_Confirmation_Date
		{
			get
			{
				return _project_Confirmation_Date;
			}
			set
			{
				SqlDateTime project_Confirmation_DateTmp = (SqlDateTime)value;
				if(project_Confirmation_DateTmp.IsNull)
				{
					throw new ArgumentOutOfRangeException("Project_Confirmation_Date", "Project_Confirmation_Date can't be NULL");
				}
				_project_Confirmation_Date = value;
			}
		}


		public SqlDecimal Project_Confirmation_DeveloperAmount
		{
			get
			{
				return _project_Confirmation_DeveloperAmount;
			}
			set
			{
                //SqlDecimal project_Confirmation_DeveloperAmountTmp = (SqlDecimal)value;
                //if(project_Confirmation_DeveloperAmountTmp.IsNull)
                //{
                //    throw new ArgumentOutOfRangeException("Project_Confirmation_DeveloperAmount", "Project_Confirmation_DeveloperAmount can't be NULL");
                //}
				_project_Confirmation_DeveloperAmount = value;
			}
		}


		public SqlDecimal Project_Confirmation_PartCommission
		{
			get
			{
				return _project_Confirmation_PartCommission;
			}
			set
			{
                //SqlDecimal project_Confirmation_PartCommissionTmp = (SqlDecimal)value;
                //if(project_Confirmation_PartCommissionTmp.IsNull)
                //{
                //    throw new ArgumentOutOfRangeException("Project_Confirmation_PartCommission", "Project_Confirmation_PartCommission can't be NULL");
                //}
				_project_Confirmation_PartCommission = value;
			}
		}


		public SqlDateTime Project_Confirmation_CommissionDate
		{
			get
			{
				return _project_Confirmation_CommissionDate;
			}
			set
			{
                //SqlDateTime project_Confirmation_CommissionDateTmp = (SqlDateTime)value;
                //if(project_Confirmation_CommissionDateTmp.IsNull)
                //{
                //    throw new ArgumentOutOfRangeException("Project_Confirmation_CommissionDate", "Project_Confirmation_CommissionDate can't be NULL");
                //}
				_project_Confirmation_CommissionDate = value;
			}
		}


		public SqlInt32 Project_Confirmation_Status
		{
			get
			{
				return _project_Confirmation_Status;
			}
			set
			{
				_project_Confirmation_Status = value;
			}
		}
		#endregion
	}
}
